#!/usr/local/bin/python2.4
# -*- coding: UTF-8 -*-
# visualisering för klubb melt
# kristoffer josefsson 2005

from vj import *
from texturegl import *

from random import *
import string

class Bridge(Scene):
	def	__init__(self):
		Scene.__init__(self)
		
		self.title = "schmelting accident"
		self.fov = 40

	def	init(self, width, height):
	
		Scene.init(self, width, height)
		
		self.bill = ImageBillboard("jojo.png")
		self.bill.make()

		glMatrixMode(GL_PROJECTION)
		glLoadIdentity()					# reset	the	projection matrix
		gluPerspective(self.fov, float(width)/float(height), 0.1, 100.0)
						# calculate	aspect ratio of	window
		glMatrixMode(GL_MODELVIEW)

	def	display(self):
		Scene.display(self)
		
		
		glTranslatef(-0.5,-0.5,-1)
		
		self.bill.draw()

		glutSwapBuffers()


	def	keyboard(self, key,	x, y):
		Scene.keyboard(self, key, x,y)
		
		if key in ['1','2','3','4','5','6']:
			self.bill.permutate(string.atoi(key))
		
		if key == 'r':
			self.bill.recreate()
		
		if key == 'o':
			for side in self.bill.sides:
				side.offset -= 0.01
		
		if key == 'O':
			for side in self.bill.sides:
				side.offset += 0.01

		if key == 'h':
			for side in self.bill.sides:
				side.height -= 0.1
		
		if key == 'H':
			for side in self.bill.sides:
				side.height += 0.1
			
		if key == 's':
			for side in self.bill.sides:
				side.softness -= 0.1
		
		if key == 'S':
			for side in self.bill.sides:
				side.softness += 0.1
if __name__=="__main__":

	s=Bridge()
	launchConsole()
	s.main(sys.argv)
	
